package megrez.bussiness.audit;

import java.time.Instant;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

/**
 * 持久化审计事数据接口
 *  
 * @author Lucky Yang
 * @since 0.0.1
 */
public interface PersistentAuditEventRepository extends JpaRepository<PersistentAuditEvent, Long> {
    /**
     * 查询
     * 
     * @param principal
     * @return
     */
    List<PersistentAuditEvent> findByPrincipal(String principal);

    /**
     * 查询
     * @param after
     * @return
     */
    List<PersistentAuditEvent> findByAuditEventDateAfter(Instant after);

    /**
     * 查询
     * @param principal
     * @param after
     * @return
     */
    List<PersistentAuditEvent> findByPrincipalAndAuditEventDateAfter(String principal, Instant after);

    /**
     * 查询
     * @param principle
     * @param after
     * @param type
     * @return
     */
    List<PersistentAuditEvent> findByPrincipalAndAuditEventDateAfterAndAuditEventType(String principle, Instant after, String type);

    /**
     * 查询
     * @param fromDate
     * @param toDate
     * @param pageable
     * @return
     */
    Page<PersistentAuditEvent> findAllByAuditEventDateBetween(Instant fromDate, Instant toDate, Pageable pageable);  
}
